using System;

using Microsoft.Extensions.DependencyInjection;

namespace NP.BPMReportPlatform.Filters
{
    public static class ApiResultServiceCollectionExtensions
    {
        public static IMvcBuilder AddCustomMvcApiResult(this IMvcBuilder builder) {
            if (builder == null) {
                throw new ArgumentNullException(nameof(builder));
            }

            return builder.AddMvcOptions(options => {
                options.Filters.Add(typeof(ApiResultFilterAttribute));
            });
        }

        public static IMvcCoreBuilder AddCustomMvcApiResult(this IMvcCoreBuilder builder) {
            if (builder == null) {
                throw new ArgumentNullException(nameof(builder));
            }

            return builder.AddMvcOptions(options =>
            {
                options.Filters.Add(typeof(ApiResultFilterAttribute));
            });
        }
    }
}